let Singleton = (function () {
    let instance = null;
    return function (name) {
        this.name = name;
        if (instance) {
            return instance;
        }
        return instance = this;
    }
})();

Singleton.prototype.getName = function () {
    return this.name;
};

function main() {
    const obj = new Singleton('demo');
    console.log(obj.getName());
}

main();
